package com.owen.spark.mysql

import org.apache.spark.sql.SparkSession

object Join {
  def main(args: Array[String]): Unit = {
    val spark=SparkSession.builder().appName("test").master("local").getOrCreate()
    val monitorPoor=spark.read
      .format("jdbc")
      .option("url","jdbc:mysql://172.22.1.151:13306/ffp_cloud_rsync?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true")
      .option("dbtable","monitor_member_sync")
      .option("user","ceo")
      .option("password","Xczx@2021")
      .load()
    monitorPoor.createOrReplaceTempView("m")

    implicit val encoder=org.apache.spark.sql.Encoders.STRING

    val data=monitorPoor.map(line=>line.getString(0)).collect()

    println(data.length)
//    val tmpMonitorPoor=spark.read
//      .format("jdbc")
//      .option("url","jdbc:mysql://172.22.1.151:13306/ffp_cloud_rsync?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true")
//      .option("dbtable","tmp_monitor_member")
//      .option("user","ceo")
//      .option("password","Xczx@2021")
//      .load()
//    tmpMonitorPoor.createOrReplaceTempView("tm")

  }
}
